<template>
  <div>
    <div class="content">
      <headerXX :name="title"></headerXX>
      <div class="content_info">
        <div class="title">
          <div style="margin-bottom: 10px">服务描述</div>
          <van-field
            type="textarea"
            v-model="description"
            height="100"
            placeholder="请输入内容"
          ></van-field>
        </div>
      </div>
      <div class="content_info">
        <!-- <div class="photo">
				<div style="margin-bottom: 10px">图片信息</div>
				<div>
						<van-uploader v-model="fileList1" @afterRead="afterRead" multiple :max-count="2" />
				</div>
			</div> -->
        <div class="btn">
          <van-button
            color="#39BCB4"
            text="确认上传"
            @click="uploadConfirm"
          ></van-button>
        </div>
        <!-- <van-modal @cancel="cancelTP" @confirm="confirmTP" :showCancelButton="true" :show="showTP"
				:title="titleTP"></van-modal> -->
      </div>
    </div>
  </div>
</template>

<script>
import { getpersonalInformation } from "../../common/RYXX";
import moment from "moment";
import { Notify } from "vant";
import headerXX from "../../components/title.vue";
import { getOrderDetailList } from "@/api/realAssets/icsharedstation/DD/index.js";
import { addServiceOrderAdminEvaluate } from "@/api/realAssets/icsharedstation/PJGL/index.js";
export default {
  components: { headerXX },
  data() {
    return {
      title: "服务凭证",
      titleTP: "本服务可上传相关服务备注信息，是否上传？",
      description: "",
      orderId: "",
      fileList1: [],
    };
  },
  created() {
    var arrayString = this.$route.query.YYXQxx;
    var array = JSON.parse(decodeURIComponent(arrayString));
    //代表修改凭证
    if (array.verification == "evaluate") {
      // showTP.value=false
      let obj = {
        orderNumber: array.orderNumber,
        postId: array.postId,
        siteId: array.siteId,
      };
      getOrderDetailList(obj).then((res) => {
        if (res.resultMessage == "SUCCESS" && res.resultCode == 1) {
          //拿到详情相应上去
          this.description = res.data.orderEvaluateAdmin.content;
          if (res.data.orderEvaluateAdmin) {
            if (res.data.orderEvaluateAdmin.img != "") {
              let imgs = res.data.orderEvaluateAdmin.img.split(",");
              imgs.forEach((item) => {
                let obj = {};
                obj.url = item;
                this.fileList1.push(obj);
              });
            }
          }
        } else {
          Notify({ type: "danger", message: "网络错误" });
        }
      });
    }
    this.orderId = array.id;
  },
  mounted() {},
  methods: {
    uploadConfirm() {
      let photoList = this.fileList1.map((item) => item.url);
      addServiceOrderAdminEvaluate({
        orderId: this.orderId,
        userName: JSON.parse(getpersonalInformation()).userName,
        content: this.description,
        img: photoList.join(","),
      })
        .then((res) => {
          //   setTimeout(() => {
          //     cancelTP();
          //   }, 2000);
          Notify({ type: "success", message: "上传成功" });
          this.$router.go(-1);
        })
        .catch((err) => {
          Notify({ type: "danger", message: "上传失败" });
        });
    },
  },
};
</script>

<style lang="less" scoped>
@import "../../static/css/index.less";
// @import "../../static/css/GYcSS.less";
.content {
  width: 100%;
  height: 100%;

  // background-color: #f5f5f5;
  // padding: 20px;
  .content_info {
    width: 100%;
  }

  .title {
    width: 90%;
    margin: 10px auto;
    height: auto;
    background-color: #fff;
    font-size: 16px;
  }

  .photo {
    width: 90%;
    margin: 10px auto;
  }
  .btn {
    width: 90%;
    height: auto;
    margin: 20px auto;
  }
}
</style>